# -*- coding: utf-8 -*-
"""
@Version : 
@Author  : ChenMZ
@Time    : 2025/09/16
@File    : MonitorUIView.py
@Desc    : 
@Modify  : 
"""
from typing import Union
from PyQt5.QtWidgets import QWidget, QHBoxLayout
from ui.DevMonitorUI.MonitorUI import Ui_Form
from . import DevMainView
from tool.global_func import DevIcon
from device.dev_interface import CPU, GPU, ETH
from view.DevMonitorUIView.CpuMonitor.CPUMainView import CpuMainView


class DevMonitorView(QWidget, Ui_Form):
    main_view: Union[CpuMainView]

    def __init__(self, dev: Union[CPU, GPU, ETH], dev_view: DevIcon):
        super().__init__()
        self.setupUi(self)
        self.device = dev
        self.device_view = dev_view
        self.setObjectName("{}_monitor".format(self.device_view.name))
        self.register_signal()

    def showEvent(self, a0):
        self.initialization()
        self.init_widget()

    def initialization(self):
        self.TitleLabel.setText(self.device_view.tr_zh)
        self.CaptionLabel.setText(self.device.get_dev_name())

    def init_widget(self):
        layout = QHBoxLayout()
        # self.main_view = CpuMainView(self.device)
        self.main_view = DevMainView[self.device_view.name].value(self.device)
        layout.addWidget(self.main_view)
        self.CardWidget.setLayout(layout)

    def register_signal(self):
        pass


